
 /* Copyright (c) 2017 by Sebastien MARCHAND (Web:www.marscaper.com, Email:sebastien@marscaper.com) 

 modify by Erinjin,changed c++ to c, 
 
 Web:https://gitee.com/ledgejin/onstep, Email: erinjin@foxmail.com
 
 */

#ifndef __CALENDAR_H__
#define __CALENDAR_H__

#include "TYPEDEF.h"


/* 儒略日结构体 */
typedef struct {
    int32 day;   /* 儒略日的整数部分 */
    float time; /* 儒略日的小数部分，表示一天中的时间 (0.0=0h 1.0=24h) */
} JulianDay;

/* 公历转儒略日 */
JulianDay julianDayForDate(float day, int month, int year);
JulianDay julianDayForDateAndTime(int day, int month, int year, 
                                 int hours, int minutes, int seconds);

/* 儒略日转公历 */
void dateForJulianDay(JulianDay julianDay, float *day, int *month, int *year);
void dateAndTimeForJulianDay(JulianDay julianDay, int *day, int *month, int *year,
                            int *hours, int *minutes, int *seconds);

/* 星期计算 */
unsigned int weekDayForDate(int day, int month, int year);
unsigned int weekDayForJulianDay(JulianDay julianDay);

#endif /* CALENDAR_H */    
